package designmode.singleton;

public enum OnlyOneObject$Enum
{
	INSTANCE;

	public static OnlyOneObject$Enum getInstance()
	{
		return INSTANCE;
	}

	// ============================================================

	public void test()
	{
		System.out.println("测试一下enum实现的单例 hashCode:" + this.hashCode() + " = toString:" + this.toString());
	}

	public static void main(String[] args)
	{
		OnlyOneObject$Enum enum1 = OnlyOneObject$Enum.getInstance();
		OnlyOneObject$Enum enum2 = OnlyOneObject$Enum.getInstance();

		enum1.test();
		enum2.test();

		System.out.println(enum1 == enum2);
	}

	// ============================================================
}
